import Vue from "vue";

Vue.prototype.$setHead = (payload) => {
  const defaultMeta = [
    { charset: "utf-8" },
    { name: "viewport", content: "width=device-width, initial-scale=1" },
    { name: "renderer", content: "webkit" },
    { name: "format-detection", content: "telephone=no" },
    { "http-equiv": "X-UA-Compatible", content: "IE=edge,chrome=1" },
    { 'http-equiv': "Cache-control", content: "no-cache,max-age=0, must-revalidate,no-store" },
  ]
  return {
    title: payload.title || "zwjun",
    htmlAttrs: payload.link ? {
      lang: "en",
      ...payload.htmlAttrs,
    } : { lang: "en" },
    link: payload.link ? [
      { rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
      // { rel: 'stylesheet', href: '/font/Tangerine.ttf' },
      ...payload.link,
    ] : [
      { rel: "icon", type: "image/x-icon", href: "/favicon.ico" },
      // { rel: 'stylesheet', href: '/font/Tangerine.ttf' }
    ],
    meta: payload.meta ? [
      ...defaultMeta,
      ...payload.meta,
    ] : defaultMeta,
  };
};
